import { getStructureTreeList } from '@/api/elementsLibrary';
export function modelAboveRefAndFunc() {
  const selectList = ref([]);
  const modelNumberList = ref([]);
  const batchList = ref([]);
  const sectionList = ref([]);
  const getStructureList = () => {
    getStructureTreeList({pageSize:9999}).then((res) => {
      if (res) {
        selectList.value = res.rows;
        modelNumberList.value = res?.rows?.filter((el) => {
          return el.parentId === 0;
        });
      }
    });
  };
  const modelChangeFunc = (e) => {
    const parentId = selectList.value.filter((el) => {
      return el.mark === e;
    });
    batchList.value = selectList.value.filter((el) => {
      return el.parentId === parentId[0]?.id;
    });
  };
  const batchChangeFunc = (e) => {
    const parentId = selectList.value.filter((el) => {
      return el.mark === e;                                                                                                                                                                                                                
    });                                                                                                                                                                                                                                      
    sectionList.value = selectList.value.filter((el) => {                                                                                                                                                                                        
      return el.parentId === parentId[0]?.id;                                                                                                                                                                                                     
    });     
  };   
  return {
    modelNumberList,
    batchList,
    sectionList,
    getStructureList,
    modelChangeFunc,
    batchChangeFunc
  }
}